package com.spring.arch.common.security;

import org.springframework.security.core.annotation.AuthenticationPrincipal;
import springfox.documentation.annotations.ApiIgnore;

import java.lang.annotation.*;

/**
 * 获取当前用户信息
 * <p>
 *    获取当前登录用户信息的方法有两种：
 * 1、@CurrentUser : @CurrentUser final UserPrincipal currentUser
 * 2、UserPrincipal principal = (UserPrincipal) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
 *    <strong>推荐使用1，尽量不要使用方法二，减少耦合</strong>
 * </p>
 * @author Frank
 * @since 2019-10-31 17:49
 */
@Target({ElementType.PARAMETER, ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
@Documented
@AuthenticationPrincipal
@ApiIgnore
public @interface CurrentUser {

}
